package xuhaijia.lanou3g.autohome.recommend.video;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import xuhaijia.lanou3g.autohome.R;

/**
 * Created by 7 on 16/8/26.
 */
public class VideoTypeAdapter extends BaseAdapter {
    Context context;
    String[] strings;
    int selection = 0;

    public VideoTypeAdapter(Context context) {

        this.context = context;
    }

    public void setSelection(int selection) {
        this.selection = selection;
    }

    public void setStrings(String[] strings) {
        this.strings = strings;
    }

    @Override
    public int getCount() {
        return strings != null ? strings.length :0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_rightdrawer_video , null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if (selection == position) {
            viewHolder.typeTv.setText(strings[position]);
            viewHolder.typeTv.setTextColor(Color.BLUE);
            viewHolder.selectIv.setVisibility(View.VISIBLE);
        } else {
            viewHolder.typeTv.setText(strings[position]);
            viewHolder.typeTv.setTextColor(Color.BLACK);
            viewHolder.selectIv.setVisibility(View.GONE);
        }

        return convertView;
    }


    public class ViewHolder {
        TextView typeTv;
        ImageView selectIv;

        public ViewHolder(View view) {
            typeTv = (TextView) view.findViewById(R.id.right_drawer_type);
            selectIv = (ImageView) view.findViewById(R.id.right_drawer_select);
        }
    }
}
